package com.wish.thriftclient.client;


import com.facebook.nifty.client.FramedClientConnector;
import com.facebook.swift.service.ThriftClientManager;
import com.google.common.net.HostAndPort;
import com.wish.thriftclient.thrift.OrderThriftService;
import com.wish.thriftclient.thrift.SwiftThriftConts;

import java.util.concurrent.ExecutionException;


/**
 * 客户端
 *
 * @author tantexian
 * @since 2017/9/27
 */
public class Client {

    public static void main(String[] args) {
        try {
            ThriftClientManager clientManager = new ThriftClientManager();
            OrderThriftService orderThriftService = clientManager.createClient(
                    new FramedClientConnector(HostAndPort.fromParts("localhost", SwiftThriftConts.DEFAULTPORT)),
                    OrderThriftService.class).get();

            System.out.println("I,m invoke server function with return result:" + orderThriftService.getOrderDetail(1l));
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
